
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)

import App from './App'
import router from './router'

Vue.prototype.IP_URL = process.env.IP_URL

import {duwenjian} from './assets/changyong.js'
Vue.prototype.duwenjian = duwenjian

axios.interceptors.request.use(function (config) {
    //拿一下token
    const token = localStorage.getItem('token')
    if(token){
      config.headers.Authorization = 'Bearer ' + token
    }
    return config;
}, function (error) {
    return Promise.reject(error);
});

axios.interceptors.response.use(
	response => {
    
		if (response.status === 200) {
			if(response.data.msg && response.data.msg.code != 0){
				if(response.data.msg.code == 401){
					router.push({path:'/login'})
				}else{
					return Promise.resolve(response);
				}
			}else{
				return Promise.resolve(response);
			}
		} else {

			return Promise.reject(response);
		}
	},
)

Vue.config.productionTip = false

new Vue({
	el: '#app',
	router,
	components: {
		App
	},
	template: '<App/>'
})
